package com.example.myui.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.example.myui.R;
import com.example.myui.adapter.MultiAdapter;
import com.example.myui.model.MultypeModel;
import com.example.myui.model.SchoolModel;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class InsertActivity extends AppCompatActivity {
    private static final String TAG = InsertActivity.class.getSimpleName();
    @BindView(R.id.recyclerview)
    RecyclerView recyclerView;
    private ArrayList<MultypeModel> multypeModels;
    private ArrayList<SchoolModel> schoolModels;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_insert);
        ButterKnife.bind(this);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(linearLayoutManager);
        MultiAdapter multiAdapter = new MultiAdapter(InsertActivity.this, initData());
        recyclerView.setAdapter(multiAdapter);
    }

    private ArrayList<MultypeModel> initData() {
        multypeModels = new ArrayList<>(3);

        for (int i = 0; i < 3; i++) {
            schoolModels = new ArrayList<>();
            if (i == 0) {
                schoolModels.add(new SchoolModel("重庆邮电大学", "2010-2014"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                schoolModels.add(new SchoolModel("重庆邮电大学1", "2011-2015"));
                multypeModels.add(new MultypeModel(schoolModels, "+ 教育经历", MultypeModel.TEXT_CONTENT));
            } else if (i == 1) {
                schoolModels.add(new SchoolModel("广东某公司", "2014-2015"));
                schoolModels.add(new SchoolModel("广东某公司", "2014-2015"));
                schoolModels.add(new SchoolModel("广东某公司", "2014-2015"));
                multypeModels.add(new MultypeModel(schoolModels, "+ 实习经历", MultypeModel.TEXT_CONTENT));
            } else if (i == 2) {
                schoolModels.add(new SchoolModel("项目经历", "2014-2015"));
                schoolModels.add(new SchoolModel("项目经历", "2014-2015"));
                schoolModels.add(new SchoolModel("项目经历", "2014-2015"));
                multypeModels.add(new MultypeModel(schoolModels, "+ 项目经历", MultypeModel.TEXT_CONTENT));
            }
        }

        return multypeModels;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 1001) {
            if (resultCode == 101) {
                Log.i(TAG, "onActivityResult: " + resultCode);
            } else if (resultCode == 102) {
                Log.i(TAG, "onActivityResult: " + resultCode);
            }

        }
    }

    public void doPlusOne(View view) {

    }
}
